<template>
    <div class="page-tab">
       <van-tabs animated swipeable @click="publish">
         <van-tab title="全部">
             <h1>精选推荐</h1>
             <page-selected :sea='data.compList'></page-selected>
             <h1>今日热搜</h1>
             <page-search :sea='data.todayList'></page-search>
             <h1>精品好菜</h1>
             <page-dish :val="data.goodList"></page-dish>
         </van-tab>
         <van-tab title="热门菜谱">
             <h2>今日热门</h2>
             <page-dish :val="data.toDayRec"></page-dish>
              <h2>本周热门</h2>
             <page-dish :val="data.weekRec"></page-dish>
              <h2>本月热门</h2>
             <page-dish :val="data.monthRec"></page-dish>
         </van-tab>
         <van-tab title="三餐推荐">
             <h2>早餐推荐</h2>
             <page-dish :val='data.compList'></page-dish>
              <h2>午餐推荐</h2>
             <page-dish :val='data.todayList'></page-dish>
              <h2>晚餐推荐</h2>
             <page-dish :val="data.goodList"></page-dish>
         </van-tab>
       </van-tabs>
    </div>
</template>

<script>
import LabelContent from './LabelContent.vue'
import PageDish from './PageDish.vue'
import PageSearch from './PageSearch.vue'
import PageSelected from './PageSelected.vue'
    export default {
       components:{LabelContent, PageDish, PageSelected, PageSearch} ,
       data() {
        return {
            data:'',
        }
       },
       methods: {
           publish(a,b){
            if(b == '全部'){
                let url = '/index/index/'+JSON.parse(sessionStorage.getItem('user')).id
                console.log(url)
                this.axios.get(url).then((res) => {
                    console.log(res.data.data)
                    this.data = res.data.data
                })
            }else if(b == '热门菜谱'){
                let url = '/index/recommend/'+JSON.parse(sessionStorage.getItem('user')).id
                this.axios.get(url).then((res) => {
                    console.log(res.data)
                    this.data = res.data.data
                })
            }else if(b == '三餐推荐'){
                let url = '/index/index/'+JSON.parse(sessionStorage.getItem('user')).id
                console.log(url)
                this.axios.get(url).then((res) => {
                    console.log(res.data.data)
                    this.data = res.data.data
                })
            }
          }  
       },
          mounted () {
           let url = '/index/index/'+JSON.parse(sessionStorage.getItem('user')).id
                this.axios.get(url).then((res) => {
                    console.log(res.data.data)
                    this.data = res.data.data
                })
        },
    }
</script>

